package org.apache.jsp;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.jsp.*;
import java.sql.*;
import pkg.Engine;

public final class index_jsp extends org.apache.jasper.runtime.HttpJspBase
    implements org.apache.jasper.runtime.JspSourceDependent {

  private static final JspFactory _jspxFactory = JspFactory.getDefaultFactory();

  private static java.util.List _jspx_dependants;

  private javax.el.ExpressionFactory _el_expressionfactory;
  private org.apache.AnnotationProcessor _jsp_annotationprocessor;

  public Object getDependants() {
    return _jspx_dependants;
  }

  public void _jspInit() {
    _el_expressionfactory = _jspxFactory.getJspApplicationContext(getServletConfig().getServletContext()).getExpressionFactory();
    _jsp_annotationprocessor = (org.apache.AnnotationProcessor) getServletConfig().getServletContext().getAttribute(org.apache.AnnotationProcessor.class.getName());
  }

  public void _jspDestroy() {
  }

  public void _jspService(HttpServletRequest request, HttpServletResponse response)
        throws java.io.IOException, ServletException {

    PageContext pageContext = null;
    HttpSession session = null;
    ServletContext application = null;
    ServletConfig config = null;
    JspWriter out = null;
    Object page = this;
    JspWriter _jspx_out = null;
    PageContext _jspx_page_context = null;


    try {
      response.setContentType("text/html");
      pageContext = _jspxFactory.getPageContext(this, request, response,
      			null, true, 8192, true);
      _jspx_page_context = pageContext;
      application = pageContext.getServletContext();
      config = pageContext.getServletConfig();
      session = pageContext.getSession();
      out = pageContext.getOut();
      _jspx_out = out;

      out.write("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"\n");
      out.write("   \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"> \n");
      out.write("\n");
      pkg.Engine Engine = null;
      synchronized (session) {
        Engine = (pkg.Engine) _jspx_page_context.getAttribute("Engine", PageContext.SESSION_SCOPE);
        if (Engine == null){
          Engine = new pkg.Engine();
          _jspx_page_context.setAttribute("Engine", Engine, PageContext.SESSION_SCOPE);
        }
      }
      out.write('\n');
      out.write('\n');

String username = request.getParameter( "username" );
String password = request.getParameter( "password" );
String logout = request.getParameter( "logout" );

      out.write('\n');

if (logout!=null&&logout.equals("1")) {
	session.removeAttribute("user");
	session.removeAttribute("Baza");
}
else if (username != null){
	Engine base = new Engine();
	if (base.connect(username, password)){
		session.setAttribute("user", username);
		session.setAttribute("Baza", base);
	}
	request.setAttribute("error_login","Bledny login");
}

      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("<html xmlns=\"http://www.w3.org/1999/xhtml\">\n");
      out.write("<head>\n");
      out.write("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n");
      out.write("<title>Baza Danych - Google API</title>\n");
      out.write("<meta name=\"Keywords\" content=\"\" />\n");
      out.write("<meta name=\"Description\" content=\"\" />\n");
      out.write("<link href=\"default.css\" rel=\"stylesheet\" type=\"text/css\" />\n");
      out.write("</head>\n");
      out.write("<body>\n");
      out.write("<div id=\"header\">\n");
      out.write("\t<a href=\"index.jsp\"><img src=\"Logo.jpg\" alt=\"Logo\" width=\"135\" height=\"100\" class=\"img2\"/></a><h1>Baza Danych - Google API</h1>\n");
      out.write("</div>\n");
      out.write("<div id=\"content\">\n");
      out.write("\t\n");
      out.write("\t<div id=\"colOne\">\n");
      out.write("\t\t");

		String login = (String) session.getAttribute( "user" );
		if (login == null) {						
			out.println("<FORM METHOD=POST ACTION=\"index.jsp\">");
			out.println("<TABLE>");
			out.println("<TR>");
				out.println("<TD width = 100>Login:</TD>");
				out.println("<TD><INPUT TYPE=TEXT NAME=username SIZE=20></TD>");
			out.println("</TR>");
			out.println("<TR>");
				out.println("<TD>HasÅo:</TD>");
				out.println("<TD><INPUT TYPE=PASSWORD NAME=password SIZE=20></TD>");
			out.println("</TR>");
			out.println("</TABLE>");
			out.println("<P align=\"center\"><INPUT TYPE=submit value=\"Zaloguj\"></P>");
			out.println("</FORM>");
			//out.println("<p align=\"left\"><a href=\"nowy.jsp\">Zarejestruj siÄ</a></p>");
		} else {
			out.println("<p align=\"center\">Zalogowano: "+login+"</p>");
			out.println("<p align=\"center\"><a href=\"index.jsp?logout=1\">Wyloguj siÄ</a></p>");
		}
			
		
      out.write("\n");
      out.write("\t\t<div id=\"menu1\">\n");
      out.write("\t\t\t<ul>\n");
      out.write("\t\t\t\t\n");
      out.write("\t\t\t</ul>\n");
      out.write("\t\t</div>\n");
      out.write("\t\t<div class=\"margin-news\">\n");
      out.write("\t\t</div>\n");
      out.write("\t</div>\n");
      out.write("\t\t\n");
      out.write("\t\t\n");
      out.write(" \n");
      out.write("\n");
      out.write("\t<div id=\"colTwo\">\n");
      out.write("\t\t");

		if (request.getAttribute("error_login")!=null){
			out.println("<h2>"+(String) request.getAttribute("error_login")+"</h2>");
			request.setAttribute("error_login",null);
		}
		
      out.write("\n");
      out.write("\t</div>\n");
      out.write("\t<div style=\"clear: both;\">&nbsp;</div>\n");
      out.write("</div>\n");
      out.write("<div id=\"footer\">\n");
      out.write("\t<p>Copyright &copy; 2008 F.Szura. Template from <a href=\"http://freecsstemplates.org\" target=\"blank\">Free CSS Templates</a></p>\n");
      out.write("</div>\n");
      out.write("</body>\n");
      out.write("</html>");
    } catch (Throwable t) {
      if (!(t instanceof SkipPageException)){
        out = _jspx_out;
        if (out != null && out.getBufferSize() != 0)
          try { out.clearBuffer(); } catch (java.io.IOException e) {}
        if (_jspx_page_context != null) _jspx_page_context.handlePageException(t);
      }
    } finally {
      _jspxFactory.releasePageContext(_jspx_page_context);
    }
  }
}
